
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0"><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>Welcome to Design Zone......</title>
<link rel="stylesheet" type="text/css"
	href="../../scripts/ext/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css"
	href="../../scripts/ext/resources/css/file-upload.css" />
<link rel="stylesheet" type="text/css" href="../../styles/dzbase.css" />
<script type="text/javascript"
	src="../../scripts/ext/adapter/ext-base.js">
		        </script>
<script type="text/javascript" src="../../scripts/ext/ext-all.js">
        </script>
<script type="text/javascript" src="../../scripts/grid/GroupSummary.js">
        </script>
<script type="text/javascript" src="../../scripts/menu/EditableItem.js">
		        </script>
<script type="text/javascript" src="../../scripts/menu/RangeMenu.js">
		        </script>
<script type="text/javascript" src="../../scripts/grid/GridFilters.js">
		        </script>
<script type="text/javascript" src="../../scripts/grid/filter/Filter.js">
		        </script>
<script type="text/javascript"
	src="../../scripts/grid/filter/StringFilter.js">
        </script>
<script type="text/javascript"
	src="../../scripts/grid/filter/ListFilter.js">
        </script>
<script type="text/javascript"
	src="../../scripts/grid/filter/DateFilter.js"></script>
<script type="text/javascript" src="../../scripts/grid/RowExpander.js">
        </script>
<script type="text/javascript"
	src="../../scripts/form/FileUploadField.js">
        </script>
<script type="text/javascript" src="../../scripts/grid/RowExpander.js">
        </script>
<script type="text/javascript" src="../../scripts/i18nMessage.js">
        </script>
<script type="text/javascript" src="../../scripts/utils.js">
        </script>
<script type="text/javascript"
	src="../../scripts/selectMeasureSpecification.js">
        </script>
<script type="text/javascript"
	src="../../scripts/multiSelectProductIdentification.js">
        </script>
<script type="text/javascript" src="../../scripts/selectBiFactory.js">
        </script>
<script type="text/javascript"
	src="../../scripts/selectBiFranceCustomer.js">
        </script>
<script type="text/javascript" src="../../scripts/selectBiArmor.js">
        </script>
<script type="text/javascript" src="../../scripts/selectDzColor.js">
        </script>
<script type="text/javascript" src="../../scripts/selectYarn.js">
        </script>
<script type="text/javascript">
            var piMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.productidentification');
            var msMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.measurespecification');
            var dzColorMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.dzcolor');
			var referenceMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.reference');
			var fcMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.francecustomer');
			var fMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.factory');
			var orderMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.order');
            var message = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=message');
            
            var idValue = getPrarmeterValue(window.location, 'id');
            var startPage = getPrarmeterValue(window.location, 'startPage');
			var input = getPrarmeterValue(window.location, 'input');
            
            var ctYesnoXmlLoader = new xmlLoader('../../servlet/CodeTableServlet?name=CtYesno');
			
			var pConfirmForm;
			var pLaunchingListStore;
            var pLaunchingListGrid;
            
            var ctYesnoStore;
            
            var isConfirmedCombo;
            
            ctYesnoStore = new Ext.data.Store({
                   
                    reader: new Ext.data.XmlReader({
                        record: 'item',
                        id: 'code',
                        totalRecords: 'itemTotal'
                    }, [
                    'code', 'description']),
					data: ctYesnoXmlLoader.getXml()
                });
            
            var piXMLReader = new Ext.data.XmlReader({
                   record: 'item'
               }, [{
                   name: 'id',
                   mapping: 'id'
               }, {
                   name: 'ctProductFamily',
                   mapping: 'ctProductFamily'
               }, {
                   name: 'ctMachineType',
                   mapping: 'ctMachineType'
               }, {
                   name: 'type',
                   mapping: 'type'
               }, {
                   name: 'orderNumber',
                   mapping: 'orderNumber'
               }, {
                   name: 'yarnNumber',
                   mapping: 'yarnNumber'
               }, {
                   name: 'ctDesignType',
                   mapping: 'ctDesignType'
               }, {
                   name: 'style',
                   mapping: 'style'
               }, {
                   name: 'customerLinkman',
                   mapping: 'customerLinkman'
               }, {
                   name: 'model',
                   mapping: 'model'
               }, {
                   name: 'ctSeasonNumber',
                   mapping: 'ctSeasonNumber'
               }, {
                   name: 'ctSeasonNumberCode',
                   mapping: 'ctSeasonNumberCode'
               }, {
                   name: 'reference',
                   mapping: 'reference'
               }, {
                   name: 'createDate',
                   mapping: 'createDate'
               }, {
                   name: 'ctVersion',
                   mapping: 'ctVersion'
               }, {
                   name: 'patronageNumer',
                   mapping: 'patronageNumer'
               }, {
                   name: 'front',
                   mapping: 'front'
               }, {
                   name: 'back',
                   mapping: 'back'
               }, {
                   name: 'sleeves',
                   mapping: 'sleeves'
               }, {
                   name: 'bottomThrum',
                   mapping: 'bottomThrum'
               }, {
                   name: 'sleevesThrum',
                   mapping: 'sleevesThrum'
               }, {
                   name: 'necklineThrum',
                   mapping: 'necklineThrum'
               }, {
                   name: 'needle',
                   mapping: 'needle'
               }, {
                   name: 'weight',
                   mapping: 'weight'
               }, {
                   name: 'comment',
                   mapping: 'comment'
               }, {
                   name: 'customerID',
                   mapping: 'customerID'
               }, {
                   name: 'photoName',
                   mapping: 'photoName'
               }, {
                   name: 'chartName',
                   mapping: 'chartName'
               }, {
                   name: 'biMeasureSpecificationId',
                   mapping: 'biMeasureSpecificationId'
               }, {
                   name: 'biMeasureSpecificationName',
                   mapping: 'biMeasureSpecificationName'
               }, {
                   name: 'yarnName',
                   mapping: 'yarnName'
               }, {
                   name: 'frontPhotoName',
                   mapping: 'frontPhotoName'
               }, {
                   name: 'backPhotoName',
                   mapping: 'backPhotoName'
               }, {
                   name: 'photoName',
                   mapping: 'photoName'
               }, {
                   name: 'chartName',
                   mapping: 'chartName'
               }, {
                   name: 'ctCollarType',
                   mapping: 'ctCollarType'
               },{
               	   name: 'ctProductIdentificationStyle',
               	   mapping: 'ctProductIdentificationStyle'
               },{
                   name: 'customerName',
                   mapping: 'customerName'
               }, {
                   name: 'customerDepartment',
                   mapping: 'customerDepartment'
               }, {
                   name: 'referenceAs',
                   mapping: 'referenceAs'
               }, {
                   name: 'createDate',
                   mapping: 'createDate'
               },{
               	   name: 'sketch1Name',
               	   mapping: 'sketch1Name'
               },{
               	   name: 'sketch2Name',
               	   mapping: 'sketch2Name'
               },{
               	   name: 'sketch3Name',
               	   mapping: 'sketch3Name'
               },{
               	   name: 'ctStatureCode',
               	   mapping: 'ctStatureCode'
               },{
               	   name: 'yarnSize1',
               	   mapping: 'yarnSize1'
               },{
               	   name: 'yarnSize2',
               	   mapping: 'yarnSize2'
               },{
               	   name: 'yarnSize3',
               	   mapping: 'yarnSize3'
               },{
               	   name: 'yarnSize4',
               	   mapping: 'yarnSize4'
               },{
               	   name: 'yarnSize5',
               	   mapping: 'yarnSize5'
               },{
               	   name: 'yarnSize6',
               	   mapping: 'yarnSize6'
               },{
               	   name: 'yarnSize7',
               	   mapping: 'yarnSize7'
               },{
               	   name: 'yarnSize8',
               	   mapping: 'yarnSize8'
               },{
               	   name: 'coefficient',
               	   mapping: 'coefficient'
               },{
               	   name: 'isConfirmed',
               	   mapping: 'isConfirmed'
               },{
               		name:'confirmedDate',
               		mapping:'confirmedDate'
               }]);
                
              var piXmlLoader = new xmlLoader('../../servlet/ProductIdentificationServlet?action=11&id=' + idValue);
              
              var piRecord = piXMLReader.readRecords(piXmlLoader.getXml()).records[0];

              isConfirmedCombo = new Ext.form.ComboBox({
					fieldLabel: orderMessage.get('ui.order.isconfirmed'),
					id: 'isConfirmed',
					name: 'isConfirmed',
					editable: false,
					valueField: 'code',
				    store: ctYesnoStore,
				    displayField:'description',
				    triggerAction: 'all',
				    emptyText: message.get('message.combo.pleaseselect'),
				    selectOnFocus:true,
				    allowBlank: false,
				    readOnly:true,
					mode: 'local',
					value: piRecord.data.isConfirmed == ''?'02':piRecord.data.isConfirmed,
					listeners: {
						select: {
							fn: function (thisComb, record,index){
								if(thisComb.getValue() == '01'){
									Ext.getCmp('confirmedDate').enable();
								}else{
									Ext.getCmp('confirmedDate').disable();
								}
							}
						}
					}
				});
              
              var itemTplMarkup = ['<table cellspacing="0" id="the-table" style="width: 100%;"><tbody>',
								 '<tr><td style="background:#eeeeee; width: 15%;">',
								 fcMessage.get('ui.francecustomer.name'), 
								 '</td><td>{customerName}</td>', 
								 '<td style="background:#eeeeee;width: 15%;">', 
								 fcMessage.get('ui.francecustomer.department'), 
								 '</td><td>{customerDepartment}</td><td style="background:#eeeeee;">', 
								 piMessage.get('ui.productidentification.seasonnumber'), 
								 '</td><td>{ctSeasonNumber}</td>', '<td style="background:#eeeeee;">', 
								 message.get('message.edit.createdate') + '(d/m/Y)', 
								 '</td><td>{createDate}</td></tr>', 
								 
								 
								 '<tr><td style="background:#eeeeee;">', 
								referenceMessage.get('ui.reference.reference'),
								 '</td><td>{reference}</td><td style="background:#eeeeee;">', 
								piMessage.get('ui.productidentification.style'), 
								 '</td><td>{ctCollarType}&nbsp;&nbsp;{ctProductIdentificationStyle}</td><td style="background:#eeeeee;">', 
								 piMessage.get('ui.productidentification.chartversion'), 
								 '</td><td>{ctVersion}</td><td style="background:#eeeeee;">', 
								piMessage.get('ui.productidentification.designtype'), 
								 '</td><td>{ctDesignType}</td></tr>',
								 
								 '<tr><td colspan="8">',
								 //'<img width="120" src="../../_temp/{frontPhotoName}"/>&nbsp;&nbsp;&nbsp;&nbsp;',
								 //'<img width="120" src="../../_temp/{backPhotoName}"/>&nbsp;&nbsp;&nbsp;&nbsp;',
								 '<img width="120" src="../../_temp/{sketch1Name}"/>&nbsp;&nbsp;&nbsp;&nbsp;',
								 '<img width="120" src="../../_temp/{sketch2Name}"/>&nbsp;&nbsp;&nbsp;&nbsp;',
								 '<img width="120" src="../../_temp/{sketch3Name}"/>',
								 '</td></tr>',
								 '</tbody></table>'];
              var itemTpl = new Ext.Template(itemTplMarkup);
              
              
              var selectDZColorCallback = function(dzColorId, dzColorCode, customerName, customerDepartment, yarnReference, ctYarnMeasure, yarnAccount,
						supplierNumber, customerColorCode, pantoneNumber, realColor,
						ctYarnMaterial1, ctYarnMaterial2, ctYarnMaterial3, ctYarnMaterial4, ctYarnMaterial5, factoryName, photo1Name, photo2Name,isApproved){
					if(isApproved == '02'){
						messageTip.msg(message.get('message.tip'), orderMessage.get('ui.order.colornotapproved'));
						return;
					}
					Ext.getCmp('dzColorId').setValue(dzColorId);
					Ext.getCmp('dzColorCode').setValue(dzColorCode);
					//Ext.getCmp('customerName').setValue(customerName);
					//Ext.getCmp('customerDepartment').setValue(customerDepartment);
					
					//Ext.getCmp('supplierNumber').setValue(supplierNumber);
					Ext.getCmp('customerColorCode').setValue(customerColorCode);
					//Ext.getCmp('pantoneNumber').setValue(pantoneNumber);
					//if(realColor && realColor != '')
					//	document.getElementById('sampleTable').style['backgroundColor'] = '#' + realColor;
					//else
					//	document.getElementById('sampleTable').style['backgroundColor'] = '#DFE8F6';
					//Ext.getCmp('factoryName').setValue(factoryName);
				}
				
				var editCallback = function(){
					pConfirmForm.getForm().load({
						url:'../../servlet/ProductLaunchingServlet?action=3&id=' + editId, 
						waitMsg:Ext.LoadMask.prototype.msg, 
						success: function(form, action){
							isConfirmedCombo.fireEvent('select');
							
						},
						failure: function(o){
							messageTip.msg(message.get('message.tip'), message.get('message.load.unsuccessful'));
						}
					});
				}
				
				var deleteCallback = function(btn){
	                if (btn == 'yes') {
	                    Ext.Ajax.request({
	                        url: '../../servlet/ProductLaunchingServlet?action=2&id=' + deleteId,
	                        success: function(o){
	                            if (o.responseText == 'success') {
	                                pLaunchingListStore.reload();
	                                messageTip.msg(message.get('message.tip'), message.get('message.delete.successful'));
	                            }
	                            else {
	                                messageTip.msg(message.get('message.tip'), message.get('message.delete.unsuccessful'));
	                            }
	                        },
	                        failure: function(o){
	                            messageTip.msg(message.get('message.tip'), message.get('message.delete.failure'));
	                        },
	                        params: {
	                            foo: 'bar'
	                        }
	                    });
	                }
	            }
	            
	            var selectYarnId;
	            var selectYarnCallback = function(yarnId, yarnReference, factoryName, ctYarnMaterial1, ctYarnMaterial2, ctYarnMaterial3, ctYarnMaterial4, ctYarnMaterial5,ctYarnMeasure,yarnAccount){
					//alert(yarnId + ' ' + factoryName + ' ' +yarnReference+ ' ' +ctYarnMaterial1+ ' ' +ctYarnMaterial2+ ' ' +ctYarnMaterial3+ ' ' +ctYarnMaterial4+ ' ' +ctYarnMaterial5);
					selectYarnId = yarnId;
					document.getElementById('yarnReference').value = yarnReference;
					document.getElementById('factoryName').value = factoryName;
					document.getElementById('ctYarnMaterial1').value = ctYarnMaterial1;
					document.getElementById('ctYarnMaterial2').value = ctYarnMaterial2;
					document.getElementById('ctYarnMaterial3').value = ctYarnMaterial3;
					document.getElementById('ctYarnMaterial4').value = ctYarnMaterial4;
					document.getElementById('ctYarnMaterial5').value = ctYarnMaterial5;
					Ext.getCmp('yarnAccount').setValue(ctYarnMeasure + ' ' + yarnAccount);
				}
				
			  var sizeNameArray = getMeasureSpecificationItemName(piRecord.data.ctStatureCode);
              Ext.onReady(function(){
				itemTpl.append('productIdentification', piRecord.data);
				
                Ext.QuickTips.init();
                Ext.form.Field.prototype.msgTarget = 'side';

				pConfirmForm = new Ext.FormPanel({
			        labelAlign: 'left',
					url: '../../servlet/ProductIdentificationServlet?action=200',
			        frame:true,
			        title: piMessage.get('ui.productidentification.approval'),
			        bodyStyle:'padding:5px 5px 5px 5px;margin-top: 2px;',
			        width: '100%',
					labelWidth: 125,
					reader: new Ext.data.XmlReader({
                        record: 'item'
                    }, [{
                        name: 'id',
                        mapping: 'id'
                    },{
                    	name: 'yarnSize1',
                    	mapping: 'yarnSize1'
                    },{
                    	name: 'yarnSize2',
                    	mapping: 'yarnSize2'
                    },{
                    	name: 'yarnSize3',
                    	mapping: 'yarnSize3'
                    },{
                    	name: 'yarnSize4',
                    	mapping: 'yarnSize4'
                    },{
                    	name: 'yarnSize5',
                    	mapping: 'yarnSize5'
                    },{
                    	name: 'yarnSize6',
                    	mapping: 'yarnSize6'
                    },{
                    	name: 'yarnSize7',
                    	mapping: 'yarnSize7'
                    },{
                    	name: 'yarnSize8',
                    	mapping: 'yarnSize8'
                    },{
                    	name: 'coefficient',
                    	mapping: 'coefficient'
                    },{
                    	name: 'confirmedDate',
                    	mapping: 'confirmedDate'
                    },{
                    	name: 'isConfirmed',
                    	mapping: 'isConfirmed'
                    }]),
					collapsible: true,
			        items: [{
	                        id: 'id',
	                        name: 'id',
	                        xtype: 'hidden',
							value: piRecord.data.id
                    	},{
                    		id: 'confirmedDate',
                            name: 'confirmedDate',
                            fieldLabel: message.get('message.edit.date') + "(d/m/Y)",
                            xtype: 'datefield',
                            allowBlank: false,
                            disabled:true,
                            readOnly:true,
                            value: piRecord.data.confirmedDate,
                            blankText: message.get('message.edit.noblank')
                        },{
							xtype: 'fieldset',
							collapsible: true,
							title: piMessage.get('ui.productidentification.yarnneed') + '(Kg)',
							autoHeight: true,
							items: [{
                            layout: 'column',
                            items: [{
                                columnWidth: .33,
                                layout: 'form',
                                items: [{
				                    xtype:'numberfield' ,
				                    fieldLabel: sizeNameArray[0],
									id: 'yarnSize1',
				                    name: 'yarnSize1',
				                    anchor:'90%',
				                    readOnly: true,
				                    value: piRecord.data.yarnSize1,
									tabIndex: 3
				                }, {
				                    xtype:'numberfield',
				                    fieldLabel: sizeNameArray[3],
									id: 'yarnSize4',
				                    name: 'yarnSize4',
				                    readOnly: true,
				                    value: piRecord.data.yarnSize4,
				                    anchor:'90%',
									tabIndex: 5
				                },{
				                    xtype:'numberfield',
				                    fieldLabel: sizeNameArray[6],
									id: 'yarnSize7',
				                    name: 'yarnSize7',
				                    readOnly: true,
				                    value: piRecord.data.yarnSize7,
				                    anchor:'90%',
				                    tabIndex: 8
								},{
				                    xtype:'numberfield',
				                    fieldLabel: message.get('message.edit.co'),
									id: 'coefficient',
				                    name: 'coefficient',
				                    readOnly: true,
				                    value: piRecord.data.coefficient,
				                    anchor:'90%',
									tabIndex: 7
				                }]
							},{
                                columnWidth: .33,
                                layout: 'form',
                                items: [{
				                    xtype:'numberfield',
				                    fieldLabel: sizeNameArray[1],
									id: 'yarnSize2',
				                    name: 'yarnSize2',
				                    value: piRecord.data.yarnSize2,
				                    readOnly: true,
				                    anchor:'90%',
									tabIndex: 3
				                },{
				                    xtype:'numberfield',
				                    fieldLabel: sizeNameArray[4],
									id: 'yarnSize5',
				                    name: 'yarnSize5',
				                    value: piRecord.data.yarnSize5,
				                    readOnly: true,
				                    anchor:'90%',
									tabIndex: 6
				                },{
				                    xtype:'numberfield',
				                    fieldLabel: sizeNameArray[7],
									id: 'yarnSize8',
				                    name: 'yarnSize8',
				                    value: piRecord.data.yarnSize8,
				                    readOnly: true,
				                    anchor:'90%',
									tabIndex: 8
				                }]
							},{
                                columnWidth: .33,
                                layout: 'form',
                                items: [{
				                    xtype:'numberfield',
				                    fieldLabel: sizeNameArray[2],
									id: 'yarnSize3',
				                    name: 'yarnSize3',
				                    value: piRecord.data.yarnSize3,
				                    readOnly: true,
				                    anchor:'90%',
									tabIndex: 4
				                },{
				                    xtype:'numberfield',
				                    fieldLabel: sizeNameArray[5],
									id: 'yarnSize6',
				                    name: 'yarnSize6',
				                    value: piRecord.data.yarnSize6,
				                    readOnly: true,
				                    anchor:'90%',
									tabIndex: 7
				                }]
							
							}]
						}]
					},isConfirmedCombo]
			    });
				
				pConfirmForm.render('pConfirmForm');

				isConfirmedCombo.fireEvent('select', isConfirmedCombo);
                
              });
        </script>
</head>
<body>
<div id="productIdentification"></div>
<div id="pConfirmForm"></div>
</body>
</html>